import React from 'react'
import {Select} from 'antd';

const Option = Select.Option;

const CustomerTypeSelect = React.createClass({

    propTypes: {//定义传入props中的属性各种类型
        value: React.PropTypes.string
    },

    defaultProps: {
        value: ''
    },

    getInitialState: function () {
        return {
            value: this.props.value || ''
        };
    },

    componentWillReceiveProps(nextProps) {
        // Should be a controlled component.
        if ('value' in nextProps) {
            const value = nextProps.value;
            this.setState(value);
        }
    },

    triggerChange: function (value) {
        const onChange = this.props.onChange;
        if (onChange) {
            onChange(Object.assign({}, this.state, { value }));
        }
    },

    render: function () {
        return (
            <Select style={{width: '100%'}} value={this.state.value} onChange={this.triggerChange}>
                <Option value="1">一般纳税人</Option>
                <Option value="2">小规模</Option>
                <Option value="3">境外</Option>
                <Option value="4">个人</Option>
            </Select>
        );
    }
});

/**
 * 客户类型
 *
 * @param defaultValue
 * @returns {XML}
 * @constructor
 */
export default CustomerTypeSelect;